﻿@model OnlineBookstore.Models.BookDetailsInfo

@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>书籍修改 - 后台管理</title>

    <!-- 引入样式 -->
    <link rel="stylesheet" href="~/conjs/bootstrap.css" />
    <link rel="stylesheet" href="~/conjs/global.css" />
    <link rel="stylesheet" href="~/conjs/cityLayout.css" />
    <link rel="stylesheet" href="~/conjs/Site.css" />

    <style>
        body {
            background-color: #f7f7f7;
            font-family: Arial, sans-serif;
            color: #333;
            margin: 0;
            padding: 0;
        }

        #header {
            background-color: #212529;
            color: #fff;
            padding: 10px 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        #logo {
            font-size: 24px;
            font-weight: bold;
        }

        #loginmsg a {
            color: #fff;
            text-decoration: none;
        }

        .container-box {
            max-width: 800px;
            margin: 30px auto;
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
        }

        h4 {
            margin-bottom: 20px;
            font-weight: bold;
            color: #333;
        }

        .form-group {
            margin-bottom: 20px;
        }

            .form-group label {
                font-weight: 600;
                display: block;
                margin-bottom: 5px;
            }

        .form-control {
            width: 100%;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 4px;
            box-sizing: border-box;
        }

        .text-danger {
            color: #dc3545;
            font-size: 12px;
        }

        .btn-primary {
            background-color: #007bff;
            border-color: #007bff;
            color: #fff;
            padding: 10px 20px;
            border-radius: 4px;
            cursor: pointer;
        }

        .btn-secondary {
            background-color: #6c757d;
            border-color: #6c757d;
            color: #fff;
            padding: 10px 20px;
            border-radius: 4px;
            cursor: pointer;
        }

        .alert {
            padding: 25px;
            border-radius: 4px;
        }

        .alert-success {
            background-color: #d4edda;
            color: #155724;
            border: 2px solid #c3e6cb;
        }

        .alert-danger {
            background-color: #f8d7da;
            color: #721c24;
            border:2px solid #f5c6cb;
        }

        .text-right {
            text-align: right;
        }

        .mt-4 {
            margin-top: 1.5rem;
        }
    </style>
</head>
<body>
    <div id="header">
        <div id="logo"><span id="logotxt">网上书城</span></div>
        <div id="loginmsg">
            @Html.ActionLink("退出", "Index", "ShopInfo", null, new { @class = "text-white" })
        </div>
        <div style="clear:both;"></div>
    </div>

    <div class="container-box">
        @using (Html.BeginForm())
        {
            @Html.AntiForgeryToken()

            <h4>书籍修改</h4>
            <hr />

            if (@TempData["SuccessMessage"] != null)
            {
                <div class="alert alert-success">@TempData["SuccessMessage"]</div>
            }


            @Html.ValidationSummary(true, "", new { @class = "alert alert-danger" })
            @Html.HiddenFor(model => model.Id)

            <div class="form-group">
                <label for="BookName">书籍名称</label>
                @Html.EditorFor(model => model.BookName, new { htmlAttributes = new { @class = "form-control", placeholder = "必填，2-100个字符" } })
                @Html.ValidationMessageFor(model => model.BookName, "", new { @class = "text-danger" })
            </div>

            <div class="form-group">
                <label for="BookAuthor">书籍作者</label>
                @Html.EditorFor(model => model.BookAuthor, new { htmlAttributes = new { @class = "form-control", placeholder = "必填，作者姓名" } })
                @Html.ValidationMessageFor(model => model.BookAuthor, "", new { @class = "text-danger" })
            </div>

            <div class="form-group">
                <label for="Bookpress">书籍出版社</label>
                @Html.EditorFor(model => model.Bookpress, new { htmlAttributes = new { @class = "form-control", placeholder = "出版社名称" } })
                @Html.ValidationMessageFor(model => model.Bookpress, "", new { @class = "text-danger" })
            </div>

            <div class="form-group">
                <label for="BookPrice">书籍价格</label>
                @Html.EditorFor(model => model.BookPrice, new { htmlAttributes = new { @class = "form-control", type = "number", step = "0.01", min = "0", placeholder = "请输入价格，如：39.99" } })
                @Html.ValidationMessageFor(model => model.BookPrice, "", new { @class = "text-danger" })
            </div>

            <div class="form-group">
                <label for="Bookcover">书籍封面</label>
                @Html.EditorFor(model => model.Bookcover, new { htmlAttributes = new { @class = "form-control", placeholder = "封面图片URL" } })
                @Html.ValidationMessageFor(model => model.Bookcover, "", new { @class = "text-danger" })
            </div>

            <div class="form-group">
                <label for="Booksort">书籍分类</label>
                @Html.EditorFor(model => model.Booksort, new { htmlAttributes = new { @class = "form-control", placeholder = "如：文学、科技" } })
                @Html.ValidationMessageFor(model => model.Booksort, "", new { @class = "text-danger" })
            </div>

            <div class="form-group text-right mt-4">
                <input type="submit" value="保存修改" class="btn btn-primary" />
                @Html.ActionLink("返回列表", "GetBookList", null, new { @class = "btn btn-secondary ml-2" })
            </div>
        }
    </div>

    <!-- 脚本区域 -->
    <script src="~/conjs/jquery-3.4.1.js"></script>
    <script src="~/conjs/bootstrap.js"></script>
    @Scripts.Render("~/bundles/jqueryval")

    <script>
        // 限制价格字段为数字输入
        $(document).ready(function () {
            $('input[type="number"]').on('keydown', function (e) {
                if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190, 37, 39]) !== -1 ||
                    (e.keyCode == 65 && e.ctrlKey === true) ||
                    (e.keyCode >= 48 && e.keyCode <= 57) ||
                    (e.keyCode >= 96 && e.keyCode <= 105)) {
                    return;
                }
                e.preventDefault();
            });
        });
    </script>
</body>
</html>
